.TH gensio_glib_funcs_alloc 3 "03 Feb 2021"
.SH NAME
gensio_glib_funcs_alloc \- Abstraction for some operating system functions
done with glib
.SH SYNOPSIS
.B #include <gensio/gensio_glib.h>
.PP
.B int gensio_glib_funcs_alloc(struct gensio_os_funcs **o)
.SH "DESCRIPTION"
This structure provides an abstraction for the gensio library that
lets it work on top of glib.  See the glib_os_funcs.3 man page for
details on what this does.  This can be used if you have a project
based on glib that you want to integrate gensio into.

Unfortunately, it has some limitations because of weaknesses in the
glib interface.

If you use this, you really want to use the gensio wait functions,
not g_cont_wait..() yourself.  you don't strictly have have to,
especially if your app is single threaded, but especially in
multithreaded apps you cannot mix calls to the os funcs wait
functions and the glib wait functions.  Which means you can't use
the blocking functions, which all use os func waiters.

Performance should be ok for a single thread.  For multiple
threads, though, only on thing at a time can be waiting on the main
glib thread.  This is a weakness in glib.  For multiple threads,
one function sits in the main context and the others sit on
condition variables.  When the thead sitting on the main context
wakes up, it wakes another waiting thread to take over.

If performance is important, it might be better to put glib on top
of gensio os funcs with
.B g_main_context_set_poll_func().
I leave that as an exercise to the reader.
.SH "RETURN VALUES"
.B A gensio_err
returns a standard gensio error.
.SH "SEE ALSO"
gensio_os_funcs(3), gensio(5), gensio_err(3)
